using System.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using System;
using YB.EnterpriseLibrary.XSLTManager.Configuration;
using YB.EnterpriseLibrary.XSLTManager.Properties;

namespace YB.EnterpriseLibrary.XSLTManager
{
    public class XSLTManagerConfigurationView
    {
        private IConfigurationSource configurationSource;

        public XSLTManagerConfigurationView(IConfigurationSource configurationSource)
        {
			this.configurationSource = configurationSource;
        }

        public XSLTManagerSettings XSLTManagerSettings
        {
            get
            {
                return (XSLTManagerSettings)configurationSource.GetSection(XSLTManagerSettings.SectionName);
            }
        }

        public string DefaultXSLTManager
        {
            get
            {
                XSLTManagerSettings configSettings = this.XSLTManagerSettings;
                return configSettings.DefaultXSLTManager;
            }
        }


        internal XSLTManagerData GetXSLTManagerData(string id)
        {
            XSLTManagerSettings configSettings = this.XSLTManagerSettings;
            XSLTManagerData data = configSettings.XSLTManagers.Get(id);
            if (data == null)
            {
                throw new ConfigurationErrorsException(string.Format(Resources.Culture, Resources.UnableToFindXSLTManagerInstance, id));
            }
            return data;
        }
    }
}
